package com.pattern.beforeclass.proxy;

import javax.swing.*;
import java.io.BufferedInputStream;
import java.io.BufferedReader;

/**
 * @Description
 * @Author Ping
 * @Date 2022/4/11 8:58
 **/
public class DecoratorPattern {
    BufferedReader reader ;
    BufferedInputStream bis ;
    JScrollPane jScrollPane ;
    public static void main(String args[]) {
        Car car = new Car() ;
        Car carTranform = new RobetTransformer(car) ;
        Car carTransform1 = new AirplaneTransformer(carTranform) ;
        car.action();
        carTranform.action();
        carTransform1.action();

    }

}


class Car {
    public void action() {
        System.out.println(" a car was moving.") ;
    }
}

abstract class CarTransformer extends Car {
    protected Car car ;

    public CarTransformer(Car car) {
        this.car = car;
    }
    @Override
    public void action() {
        this.car.action();
        transform();
    }
    public abstract void transform() ;
}

class RobetTransformer extends CarTransformer {
    public RobetTransformer(Car car) {
        super(car);
    }

    @Override
    public void transform() {
        System.out.println("and transform to a ROBERT.") ;
    }
}

class AirplaneTransformer extends CarTransformer {
    public AirplaneTransformer(Car car) {
        super(car);
    }

    @Override
    public void transform() {
        System.out.println("and transform to a Airplane.") ;
    }
}